@extends('web.common.main')
@section('headmeta')
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
@endsection
@section('css')
    <link rel="stylesheet" href="{{env('SOURCE_PATH')}}css/act1.css">
@endsection
@section('container')
<div class="act1_head act1_head_pv">
    <h1>光伏专题征集
        <small>关于居民家庭屋顶光伏项目的技术设备供应商、实施方征集</small>
    </h1>
    <img src="/dev/img/act1-banner.png" alt="">
</div>
<div class="act1_con">
    <div class="act1_body">
        <div class="act1_section">
            <div class="title">项目简介</div>
            <div class="content">
                <p>
                    浙江碳银与湖州某地政府达成区域低碳发展的合作协议，由碳银为当地的节能环保项目提供一揽子解决方案，其中双方的启动项目为“光伏小镇”建设工程，将为不少于1000户的农居屋顶安装光伏电站。该项目预计4月中旬正式实施，现征集优质组件生产厂商（含光伏板、逆变器、配电箱等）和光伏项目的安装施工方（自行解决支架及配套辅材）。</p>
            </div>
        </div>
        <div class="act1_section">
            <div class="title">政策导向</div>
            <div class="subtit">国家层面</div>
            <div class="content">
                <p class="dot">“十三五”将是太阳能产业发展的关键时期，国家将持续推动光伏产业升级，扩大光伏产品的应用。</p>
                <p class="dot">到2020年底，太阳能发电装机容量达到1.6亿千瓦，年发电量达到1700亿千瓦时；年度总投资额约2000亿元。</p>
            </div>
            <div class="subtit">浙江层面</div>
            <div class="content">
                <p class="dot">浙江省光伏补贴发放速度、银行系统支持力度均位于全国前列，“十三五”期间将继续推动光伏项目建设。</p>
                <p class="dot">截止十二五末，浙江省光伏发电装机达到 220 万千瓦，年平均增长率130%，屋顶分布式光伏发电总装机容量规模位居全国第一。</p>
                <p class="dot">十三五期间，全省光伏发电规划将达到800万千瓦以上，屋顶分布式光伏建设规模达 360 万千瓦以上。</p>
                <p class="dot">以技术创新进步为核心，以智能电网建设为支撑，加快屋顶分布式、地面集中式、家庭户用式光伏等太阳能利用。</p>
            </div>
        </div>
        <div class="act1_section">
            <div class="title">市场空间</div>
            <div class="content">
                <p>
                    以浙江省杭州、湖州、宁波为例，2016-2020年三地预计完成29.5万户家庭屋顶光伏项目建设，总装机规模88.5万千瓦左右。其中湖州人口总数仅占杭州人口总数的29%，占宁波人口总数的34%，而湖州建家庭屋顶光伏项目设数却占到了杭州建设数的95%，占宁波建设数的111%。与杭州、宁波相比，湖州地区有着巨大的光伏项目发展潜力。</p>
            </div>
        </div>
        <div class="act1_section">
            <div class="title">联系方式</div>
            <div class="content">
                <ul class="contact">
                    <li>联系人：田经理</li>
                    <li>联系电话：0571 8292 9382</li>
                    <li>联系邮箱：tianbl@tanwin.cn</li>
                </ul>
            </div>
        </div>
        <div class="act1_section act1-media_fixed">
            <div class="title">网上报名</div>
            <div class="content">
                <a href="#supplier" class="btn btn-half">技术设备供应商报名</a>
                <a href="#worker" class="btn btn-half btn-reverse">实施方报名</a>
            </div>
        </div>
    </div>
    <div class="act1_body" style="display: none">
        <div class="act1_section">
            <div class="act1_form">
                <div class="title"><span>技术设备供应商报名表</span></div>
                <div class="form-group">
                    <label class="require" for="company_name">企业名称</label>
                    <input type="text" class="form-control" id="company_name" maxlength="200">
                </div>
                <div class="form-group">
                    <label class="require" for="user_name">企业联系人</label>
                    <input type="text" class="form-control form-control_sm" id="user_name" maxlength="20">
                </div>
                <div class="form-group">
                    <label class="require" for="user_phone">企业联系电话</label>
                    <input type="text" class="form-control form-control_sm" id="user_phone" maxlength="11">
                </div>
                <div class="form-group">
                    <label class="require" for="company_desc">企业概况</label>
                    <textarea class="form-control" id="company_desc" maxlength="500" rows="6"></textarea>
                </div>
                <div class="form-group">
                    <label class="require" for="tech_device_case">供应项</label>
                    <div class="act1_tech">
                        <ul class="j_techItem"></ul>
                        <a class="btn btn-warning j_newItem">新增供应项</a>
                        <input type="hidden" id="tech_id" value="">
                        <div class="media-bg j_popBg" style="display: none"></div>
                        <div class="table j_itemTable" style="display: none">
                            <div class="form-group">
                                <label for="tech_device_type">技术/设备分类</label>
                                <select class="form-control form-control_sm" id="tech_device_type">
                                    @forelse(@$list as $key=>$value)
                                        <option value="{{$key}}">{{$value}}</option>
                                    @empty

                                    @endforelse
                                </select>
                                <label class="require" for="tech_device_name">名称</label>
                                <input type="text" class="form-control form-control_sm" id="tech_device_name"
                                       maxlength="60">
                            </div>
                            <div class="form-group">
                                <label for="tech_device_brand">品牌</label>
                                <input type="text" class="form-control form-control_sm" id="tech_device_brand"
                                       maxlength="60">
                                <label>是否有专利</label>
                                <label class="radio" for="tech_device_bool_patent1">
                                    <input id="tech_device_bool_patent1" name="tech_device_bool_patent" value="1"
                                           type="radio" checked> 是
                                </label>
                                <label class="radio" for="tech_device_bool_patent0">
                                    <input id="tech_device_bool_patent0" name="tech_device_bool_patent" value="0"
                                           type="radio"> 否
                                </label>
                            </div>
                            <div class="form-group">
                                <label for="tech_device_price">系统集成单价/瓦</label>
                                <input type="text" class="form-control form-control_sm" id="tech_device_price"
                                       maxlength="20">
                                <label for="tech_device_fix_years">维保期限</label>
                                <input type="text" class="form-control form-control_sm" id="tech_device_fix_years"
                                       maxlength="20">
                            </div>
                            <div class="form-group">
                                <label for="tech_device_point">技术特点</label>
                                <textarea class="form-control" id="tech_device_point" maxlength="500"
                                          rows="3"></textarea>
                            </div>
                            <div class="form-group">
                                <label for="tech_device_case">典型案例</label>
                                <textarea class="form-control" id="tech_device_case" maxlength="500"
                                          rows="3"></textarea>
                            </div>
                            <div class="form-group">
                                <div class="text-center">
                                    <a class="btn btn-reverse j_submitItem">确定</a>
                                    <a class="btn j_cancelItem">取消</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="content">
                <a class="btn btn-reverse j_submitSupplier">提交报名信息</a>
                <a class="btn j_backUrl">返回</a>
            </div>
        </div>
    </div>
    <div class="act1_body" style="display: none">
        <div class="act1_section">
            <div class="act1_form">
                <div class="title"><span>实施方报名表</span></div>
                <div class="form-group">
                    <label class="require" for="worker_company_name">企业名称</label>
                    <input type="text" class="form-control" id="worker_company_name" maxlength="200">
                </div>
                <div class="form-group">
                    <label class="require" for="worker_user_name">企业联系人</label>
                    <input type="text" class="form-control form-control_sm" id="worker_user_name" maxlength="20">
                </div>
                <div class="form-group">
                    <label class="require" for="worker_user_phone">企业联系电话</label>
                    <input type="text" class="form-control form-control_sm" id="worker_user_phone" maxlength="11">
                </div>
                <div class="form-group">
                    <label class="require" for="worker_company_desc">企业概况</label>
                    <textarea class="form-control" id="worker_company_desc" maxlength="500" rows="6"></textarea>
                </div>
                <div class="form-group">
                    <label class="require" for="worker_tech_device_price">每瓦安装单价</label>
                    <input type="text" class="form-control form-control_xs" id="worker_tech_device_price"
                           maxlength="20">
                </div>
                <div class="form-group">
                    <label class="require" for="worker_fix_per_time">每户安装工时</label>
                    <input type="text" class="form-control form-control_xs" id="worker_fix_per_time"
                           maxlength="20">
                </div>
                <div class="form-group">
                    <label class="require" for="worker_tech_device_fix_years">维保期限</label>
                    <input type="text" class="form-control form-control_xs" id="worker_tech_device_fix_years"
                           maxlength="20">
                </div>
                <div class="form-group">
                    <label class="require" for="worker_tech_device_case">典型案例</label>
                    <textarea class="form-control" id="worker_tech_device_case" maxlength="2000" rows="12"></textarea>
                </div>
            </div>
            <div class="content">
                <a class="btn btn-reverse j_submitWorker">提交报名信息</a>
                <a class="btn j_backUrl">返回</a>
            </div>
        </div>
    </div>
</div>
@endsection
@section('script')
<script>
    (function ($) {
        $(function () {
            //新增供应项
            $('.j_newItem').on('click', function () {
                resetItemForm();
                $('.j_itemTable,.j_popBg').css('display', 'block');
            });
            $('.j_techItem').on('click', '.j_editItem', function () {
                //編輯供应项
                var $p = $(this).parents('li');
                $('#tech_id').val($('.j_techItem li').index($p));
                $('#tech_device_type').val($p.find('.j_tech_device_type').val());
                $('#tech_device_name').val($p.find('.j_tech_device_name').val());
                $('#tech_device_brand').val($p.find('.j_tech_device_brand').val());
                if ($p.find('.j_tech_device_bool_patent').val() == 1) {
                    $('#tech_device_bool_patent1').prop('checked', true);
                } else {
                    $('#tech_device_bool_patent0').prop('checked', true);
                }
                $('#tech_device_price').val($p.find('.j_tech_device_price').val());
                $('#tech_device_fix_years').val($p.find('.j_tech_device_fix_years').val());
                $('#tech_device_point').val($p.find('.j_tech_device_point').val());
                $('#tech_device_case').val($p.find('.j_tech_device_case').val());
                $('.j_itemTable,.j_popBg').css('display', 'block');
            }).on('click', '.j_delItem', function () {
                //刪除供应项
                //如果刪除项是当前编辑项，删除会改变li的index值，将影响编辑项的保存位置，暂不做处理
                //if($('.j_techItem li').index($(this).parents('li')) == $('#tech_id').val()){
                resetItemForm();
                $('.j_itemTable,.j_popBg').css('display', 'none');
                //}
                $(this).parents('li').remove();
            });
            //重置供应项表单
            function resetItemForm() {
                $('#tech_id').val('');
                $('#tech_device_type').val('');
                $('#tech_device_name').val('');
                $('#tech_device_brand').val('');
                $('#tech_device_bool_patent1').prop('checked', true);
                $('#tech_device_price').val('');
                $('#tech_device_fix_years').val('');
                $('#tech_device_point').val('');
                $('#tech_device_case').val('');
            }

            //保存供应项
            $('.j_submitItem').on('click', function () {
                var $btn = $(this);
                var maxlen = 0;
                var $tech_device_type = $("#tech_device_type");
                var tech_device_type = $tech_device_type.val();
                var tech_device_type_text = $tech_device_type.find('option:selected').text();

                var $tech_device_name = $("#tech_device_name");
                maxlen = $tech_device_name.attr('maxlength');
                var tech_device_name = $tech_device_name.val();
                if (!tech_device_name || tech_device_name.length > maxlen) {
                    return showErr($tech_device_name, "请输入名称，" + maxlen + "字以内");
                }
                var $tech_device_brand = $("#tech_device_brand");
                maxlen = $tech_device_brand.attr('maxlength');
                var tech_device_brand = $tech_device_brand.val();
                if (tech_device_brand.length > maxlen) {
                    return showErr($tech_device_brand, maxlen + "字以内");
                }
                var tech_device_bool_patent = $('[name="tech_device_bool_patent"]:checked').val();
                var $tech_device_price = $("#tech_device_price");
                maxlen = $tech_device_price.attr('maxlength');
                var tech_device_price = $tech_device_price.val();
                if (tech_device_price.length > maxlen || (tech_device_price && !isInt(tech_device_price) && !isFloat(tech_device_price, 1) && !isFloat(tech_device_price))) {
                    return showErr($tech_device_price, maxlen + "字以内，允许两位小数");
                }
                var $tech_device_fix_years = $("#tech_device_fix_years");
                maxlen = $tech_device_fix_years.attr('maxlength');
                var tech_device_fix_years = $tech_device_fix_years.val();
                if (tech_device_fix_years.length > maxlen) {
                    return showErr($tech_device_fix_years, maxlen + "字以内");
                }
                var $tech_device_point = $("#tech_device_point");
                maxlen = $tech_device_point.attr('maxlength');
                var tech_device_point = $tech_device_point.val();
                if (tech_device_point.length > maxlen) {
                    return showErr($tech_device_point, maxlen + "字以内");
                }
                var $tech_device_case = $("#tech_device_case");
                maxlen = $tech_device_case.attr('maxlength');
                var tech_device_case = $tech_device_case.val();
                if (tech_device_case.length > maxlen) {
                    return showErr($tech_device_case, maxlen + "字以内");
                }
                var id = $('#tech_id').val();
                var html = '';
                var $p = $('.j_techItem');
                html += '<div class="form-group">' +
                        '<a class="edit j_editItem">编辑</a>' +
                        '<label>名称</label>' +
                        '<div class="form-control_text">' + tech_device_name + '</div>' +
                        '</div>' +
                        '<div class="form-group">' +
                        '<a class="del j_delItem">删除</a>' +
                        '<label>技术/设备分类</label>' +
                        '<div class="form-control_text">' + tech_device_type_text + '</div>' +
                        '</div>' +
                        '<input type="hidden" class="j_tech_device_type" value="' + tech_device_type + '">' +
                        '<input type="hidden" class="j_tech_device_name" value="' + tech_device_name + '">' +
                        '<input type="hidden" class="j_tech_device_brand" value="' + tech_device_brand + '">' +
                        '<input type="hidden" class="j_tech_device_bool_patent" value="' + tech_device_bool_patent + '">' +
                        '<input type="hidden" class="j_tech_device_price" value="' + tech_device_price + '">' +
                        '<input type="hidden" class="j_tech_device_fix_years" value="' + tech_device_fix_years + '">' +
                        '<input type="hidden" class="j_tech_device_point" value="' + tech_device_point + '">' +
                        '<input type="hidden" class="j_tech_device_case" value="' + tech_device_case + '">';
                if (!id) {
                    $p.append('<li>' + html + '</li>');
                } else {
                    $p.find('li').eq(id).html(html);
                }
                $('.j_itemTable,.j_popBg').css('display', 'none');

            });
            //取消
            $('.j_cancelItem').on('click', function () {
                $('.j_itemTable,.j_popBg').css('display', 'none');
            });
            //提交技术设备供应商报名信息
            $('.j_submitSupplier').on('click', function () {
                var $btn = $(this);
                var maxlen = 0;
                var $company_name = $("#company_name");
                maxlen = $company_name.attr('maxlength');
                var company_name = $company_name.val();
                if (!company_name || company_name.length > maxlen) {
                    return showErr($company_name, "请输入企业名称，" + maxlen + "字以内");
                }
                var $user_name = $("#user_name");
                maxlen = $user_name.attr('maxlength');
                var user_name = $user_name.val();
                if (!user_name || user_name.length > maxlen) {
                    return showErr($user_name, "请输入企业联系人，" + maxlen + "字以内");
                }
                var $user_phone = $("#user_phone");
                maxlen = $user_phone.attr('maxlength');
                var user_phone = $user_phone.val();
                if (!user_phone || user_phone.length > maxlen || !isPhone(user_phone)) {
                    return showErr($user_phone, "请输入企业联系电话，必须是手机号码");
                }
                var $company_desc = $("#company_desc");
                maxlen = $company_desc.attr('maxlength');
                var company_desc = $company_desc.val();
                if (!company_desc || company_desc.length > maxlen) {
                    return showErr($company_desc, "请输入企业概况，" + maxlen + "字以内");
                }
                var tech_device_list = [];
                var i = 0, $tech_device_list = $('.j_techItem'), techLen = $tech_device_list.find('li').length;
                if (techLen === 0) {
                    return showErr($company_desc, "至少需要一条供应项记录");
                }
                for (; i < techLen; i++) {
                    var $li = $tech_device_list.find('li').eq(i);
                    tech_device_list.push({
                        'tech_device_type': $li.find('.j_tech_device_type').val(),
                        'tech_device_name': $li.find('.j_tech_device_name').val(),
                        'tech_device_brand': $li.find('.j_tech_device_brand').val(),
                        'tech_device_bool_patent': $li.find('.j_tech_device_bool_patent').val(),
                        'tech_device_price': $li.find('.j_tech_device_price').val(),
                        'tech_device_fix_years': $li.find('.j_tech_device_fix_years').val(),
                        'tech_device_point': $li.find('.j_tech_device_point').val(),
                        'tech_device_case': $li.find('.j_tech_device_case').val()
                    });
                }
                $.ajax({
                    url: "/form",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        form_type: 'tech_device',
                        user_name: user_name,
                        user_phone: user_phone,
                        company_name: company_name,
                        company_desc: company_desc,
                        tech_device_list: tech_device_list
                    },
                    type: "POST",
                    dataType: "json",
                    success: function (data) {
                        if (data["result"] == 0) {
                            $.Alert({
                                obj: $btn, txt: '提交成功！', callback: function () {
                                    $("#j_alert").remove();
                                    location.hash = hashs[0];
                                }
                            });
                        } else {
                            $.Alert({
                                obj: $btn, txt: data["msg"], type: 'danger'
                            });
                        }
                    }
                });
            });
            //提交实施方报名信息
            $('.j_submitWorker').on('click', function () {
                var $btn = $(this);
                var maxlen = 0;
                var $worker_company_name = $("#worker_company_name");
                maxlen = $worker_company_name.attr('maxlength');
                var worker_company_name = $worker_company_name.val();
                if (!worker_company_name || worker_company_name.length > maxlen) {
                    return showErr($worker_company_name, "请输入企业名称，" + maxlen + "字以内");
                }
                var $worker_user_name = $("#worker_user_name");
                maxlen = $worker_user_name.attr('maxlength');
                var worker_user_name = $worker_user_name.val();
                if (!worker_user_name || worker_user_name.length > maxlen) {
                    return showErr($worker_user_name, "请输入企业联系人，" + maxlen + "字以内");
                }
                var $worker_user_phone = $("#worker_user_phone");
                maxlen = $worker_user_phone.attr('maxlength');
                var worker_user_phone = $worker_user_phone.val();
                if (!worker_user_phone || worker_user_phone.length > maxlen || !isPhone(worker_user_phone)) {
                    return showErr($worker_user_phone, "请输入企业联系电话，必须是手机号码");
                }
                var $worker_company_desc = $("#worker_company_desc");
                maxlen = $worker_company_desc.attr('maxlength');
                var worker_company_desc = $worker_company_desc.val();
                if (!worker_company_desc || worker_company_desc.length > maxlen) {
                    return showErr($worker_company_desc, "请输入企业概况，" + maxlen + "字以内");
                }
                var $worker_tech_device_price = $("#worker_tech_device_price");
                maxlen = $worker_tech_device_price.attr('maxlength');
                var worker_tech_device_price = $worker_tech_device_price.val();
                if (!worker_tech_device_price || worker_tech_device_price.length > maxlen || (!isInt(worker_tech_device_price) && !isFloat(worker_tech_device_price, 1) && !isFloat(worker_tech_device_price))) {
                    return showErr($worker_tech_device_price, "请输入每瓦安装单价，" + maxlen + "字以内，允许两位小数");
                }
                var $worker_fix_per_time = $("#worker_fix_per_time");
                maxlen = $worker_fix_per_time.attr('maxlength');
                var worker_fix_per_time = $worker_fix_per_time.val();
                if (!worker_fix_per_time || worker_fix_per_time.length > maxlen) {
                    return showErr($worker_fix_per_time, "请输入每户安装工时，" + maxlen + "字以内");
                }
                var $worker_tech_device_fix_years = $("#worker_tech_device_fix_years");
                maxlen = $worker_tech_device_fix_years.attr('maxlength');
                var worker_tech_device_fix_years = $worker_tech_device_fix_years.val();
                if (!worker_tech_device_fix_years || worker_tech_device_fix_years.length > maxlen) {
                    return showErr($worker_tech_device_fix_years, "请输入维保期限，" + maxlen + "字以内");
                }
                var $worker_tech_device_case = $("#worker_tech_device_case");
                maxlen = $worker_tech_device_case.attr('maxlength');
                var worker_tech_device_case = $worker_tech_device_case.val();
                if (!worker_tech_device_case || worker_tech_device_case.length > maxlen) {
                    return showErr($worker_tech_device_case, "请输入典型案例，" + maxlen + "字以内");
                }
                $.ajax({
                    url: "/form",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        form_type: 'worker',
                        user_name: worker_user_name,
                        user_phone: worker_user_phone,
                        company_name: worker_company_name,
                        company_desc: worker_company_desc,
                        tech_device_price: worker_tech_device_price,
                        tech_device_fix_years: worker_tech_device_fix_years,
                        fix_per_time: worker_fix_per_time,
                        tech_device_case: worker_tech_device_case
                    },
                    type: "POST",
                    dataType: "json",
                    success: function (data) {
                        if (data["result"] == 0) {
                            $.Alert({
                                obj: $btn, txt: '提交成功！', callback: function () {
                                    $("#j_alert").remove();
                                    location.hash = hashs[0];
                                }
                            });
                        } else {
                            $.Alert({
                                obj: $btn, txt: data["msg"], type: 'danger'
                            });
                        }
                    }
                });
            });

            var hashs = ['', 'supplier', 'worker'];
            hashChange();

            //返回
            $('.j_backUrl').on('click', function () {
                location.hash = hashs[0];
            });

            function hashChange(hash) {
                if (!hash) {
                    hash = location.hash;
                    if (!hash) {
                        hash = hashs[0];//没有任何hash值默认第一个
                    }
                }
                hash = hash.replace("#", "");
                var index = 0;
                for (var i = 0, l = hashs.length; i < l; i++) {
                    if (hashs[i] === hash) {
                        index = i;
                        break;
                    }
                }
                //开始执行对应hash内容变化
                $(".act1_body").css("display", "none").eq(index).css("display", "block");
            }

            window.onhashchange = function () {
                hashChange(location.hash);
            };
        });
    })(jQuery);
</script>


@endsection
